Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTC: Call on_play before create session, for it might be freed for timeout. #3455

Merged
merged 3 commits into from
Mar 25, 2023

Conversation

xiaozhihong
Copy link
Collaborator

@xiaozhihong xiaozhihong commented Mar 7, 2023

When callback the on_play, it might be blocked and context will be switched to other coroutine, then the created session might be freed for timeout. After the callback is done, the destroied session will be used and cause the crash.

I changed the order to call on_play before create session, in order to avoid destroying the session object. However, the best solution is use shared ptr, and we're developing it.

@xiaozhihong xiaozhihong linked an issue Mar 7, 2023 that may be closed by this pull request
@xiaozhihong
Copy link
Collaborator Author

xiaozhihong commented Mar 7, 2023

6a108fab6d#diff-2d94fb08a8b76aa40f71a392bb00afc19bb96767bd874cf74582a011488dc88cR207

Here is a comment written, stating that there is a sequential dependency, but from the code, there doesn't seem to be any dependency.

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Mar 7, 2023

6a108fab6d#diff-2d94fb08a8b76aa40f71a392bb00afc19bb96767bd874cf74582a011488dc88cR207

Here is a comment stating that there is a sequential dependency, but from the code it doesn't seem to have any dependency.

'on_play' depends on the object created by 'stat', but it shouldn't have any dependency here. There must be dependencies in other places.

This comment is mainly a reminder that calling it before 'stat' will result in the client id not being found.

TRANS_BY_GPT3

@limjoe
Copy link

limjoe commented Mar 10, 2023

@xiaozhihong I haven't enabled webrtc protocol distribution on my side, only http-flv and rtmp live protocol distribution are enabled, but it still reports the crash mentioned in #3413.

TRANS_BY_GPT3

@winlinvip winlinvip force-pushed the develop branch 3 times, most recently from c056094 to 2ac9eb8 Compare March 23, 2023 06:02
@winlinvip winlinvip changed the title RTC: fix crash on play RTC: Call on_play before create session, because the session might be freed for timeout. Mar 25, 2023
@winlinvip winlinvip changed the title RTC: Call on_play before create session, because the session might be freed for timeout. RTC: Call on_play before create session, for it might be freed for timeout. Mar 25, 2023
@winlinvip winlinvip merged commit d875571 into ossrs:develop Mar 25, 2023
winlinvip added a commit that referenced this pull request Mar 25, 2023
…meout. v5.0.149, v6.0.37 (#3455)

PICK d875571

Co-authored-by: winlin <winlin@vip.126.com>
Co-authored-by: ChenGH <chengh_math@126.com>
duiniuluantanqin pushed a commit to duiniuluantanqin/srs that referenced this pull request Mar 31, 2023
…meout. v5.0.149, v6.0.37 (ossrs#3455)

Co-authored-by: winlin <winlin@vip.126.com>
Co-authored-by: ChenGH <chengh_math@126.com>
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebRTC: AddressSanitizer: heap-use-after-free
4 participants